package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.web.framework.annotation.config.stereotype.Autowired;
import com.lagou.web.framework.annotation.config.stereotype.Controller;
import com.lagou.web.framework.mvc.config.annotations.RequestMapping;
import com.lagou.web.framework.mvc.config.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("demo")
@Security(value = "lisi")
public class DemoController {
    @Autowired
    private IDemoService iDemoService;

    /**
     * URL: http:localhost:8080/demo/query?username=zhangsan
     *
     * @param request
     * @param response
     * @param name
     * @return
     */
    @RequestMapping("query")
    @Security(value = "zhangsan")
    public String query(HttpServletRequest request, HttpServletResponse response, String name) {
        iDemoService.get(name);
        return "/WEB-INF/jsp/welcome.jsp";
    }

    @RequestMapping("query2")
    @Security
    public String query2(HttpServletRequest request, HttpServletResponse response, String name) {
        iDemoService.get(name);
        return "/WEB-INF/jsp/welcome2.jsp";
    }

    @RequestMapping("query3")
    public String query3(HttpServletRequest request, HttpServletResponse response, String name) {
        iDemoService.get(name);
        return "/WEB-INF/jsp/welcome3.jsp";
    }
}
